* {
  margin: 0;
  padding: 0;
  outline: none;
  border: none;
}

:host {
  display: inline-block;
  max-width: 300px;
  min-width: 200px;
  font-family: sans-serif;
  color: #555;
  font-size: 0.85rem;
}

#wrapper {
  position: relative;
}

#selection {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  row-gap: 0.25rem;
  column-gap: 0.25rem;
  padding: 0.25rem 0.25rem;
  border: 1px solid #DDD;
  border-radius: 2px;
  background: #fff;
  cursor: text;
}

#items {
  display: contents;
}

.item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-radius: 0.25rem;
  background:#EAEAEA;
  cursor: grab;
  user-select: none;
}

.item.animate {
  animation: popIn 0.3s;
}

@keyframes popIn {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }
  70% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.item.dragged {
  position: relative;
  visibility: hidden;
  animation: none;
}

.item.dragged::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: dashed 1px gray;
  visibility: visible;
  border-radius: inherit;
}

.item-inner-text {
  padding: 0.25rem 0.5rem;
}

.item-remove-button {
  padding: 0.25rem 0.5rem;
  background: none;
  cursor: pointer;
  color: inherit;
  font-size: 0.75em;
}

.item-remove-button:hover,
.item-remove-button:focus-visible {
  color: #FF6347;
}

.item-remove-button::before {
  content: "\2715";
}

#search {
  flex: 1;
  min-width: 3rem;
  padding: 0.25rem 0.5rem;
  font-size: inherit;
  background: none;
  color: inherit;
}

#dropdown {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 0.25rem 0.25rem;
  border: 1px solid #EAEAEA;
  border-top: none;
  border-bottom-left-radius: 0.25rem;
  border-bottom-right-radius: 0.25rem;
  background: #fff;
  overflow-y: auto;
  box-sizing: border-box;
  max-height: calc(100vh - (var(--bboxY) + var(--bboxHeight)) * 1px);
  z-index: 1;
}

#dropdown.no-results::before {
  content: attr(data-placeholder);
  padding: 0.5rem 0.5rem;
}

#dropdown.shift {
  top: auto;
  bottom: 100%;
  max-height: calc(var(--bboxY) * 1px);
}

#dropdown.animate {
  animation: showDropdown 0.3s;
}

@keyframes showDropdown {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#dropdown.hidden {
  display: none;
}

#dropdown.hidden.animate {
  display: flex;
  animation: hideDropdown 0.3s;
}

@keyframes hideDropdown {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

#dropdown::slotted(*) {
  padding: 0.5rem 0.5rem;
  border-radius: 0.25rem;
  cursor: default;
}

#dropdown::slotted(*:focus) {
  outline: none;
}

#dropdown::slotted(*:hover),
#dropdown::slotted(*:focus-visible) {
  background-color: #EAEAEA;
}

#dropdown::slotted([disabled]) {
  color: #EAEAEA;
  background-color: transparent;
}

/* show label or value if item is empty */

#dropdown::slotted(:empty[value])::before {
  content: attr(value);
}

#dropdown::slotted(:empty[label])::before {
  content: attr(label);
}